Page({
    data: {
        fileList: []
    },
    afterRead(event) {
        const { file } = event.detail;
        let fileList = file.map(item => {
            return { url: item.url }
        })
        this.setData({
            fileList
        })
    },
    async add() {
        //上传到服务器云存储
        let arr = []
        this.data.fileList.forEach(async item => {
            let ext = /\.[^\.]\w*$/.exec(item.url)[0]
            let pro = await wx.cloud.uploadFile({
                cloudPath: "cloud/" + new Date().getTime() + Math.floor(Math.random() * 100) + ext,
                filePath: item.url
            })
            arr.push(pro)

        })
        console.log(arr)
        let result = await Promise.all(arr)
        // console.log(result)



    }
})